package com.mysoft.gfyx.marketdevelop.mip.dto.TjCustom;

import com.google.common.base.Joiner;
import com.mysoft.gfyx.marketdevelop.mip.dto.SearchBaseRequestDto;
import lombok.Data;

import java.util.ArrayList;

@Data
public class MohurdProjectListRequestDto extends SearchBaseRequestDto {
    private String id;
    private String prj_num;
    private String keyword;
    private String province_code;
    private String city_code;
    private String company_type_label;
    private String time_type;
    private String time_begin;
    private String time_end;
    private String build_corp_name;
    private String prj_name;
    private String is_price_gt_avg;
    private String prj_type_num;
    private String prj_property_num;

    private String prj_approval_date_start;
    private String prj_approval_date_end;
    private String tender_result_date_end;
    private String tender_result_date_start;
    private String contract_date_start;
    private String contract_date_end;
    private String release_date_start;
    private String release_date_end;
    private String begin_date_start;
    private String begin_date_end;
    private String end_date_start;
    private String end_date_end;

    private String is_all_time;//1：立项时间、中标时间、合同签订、开工许可证、计划开工时间、计划竣工时间 ，或的关系

    private int pageNum;
    private int pageSize;

    protected void setFilterByField(String field, String operatorType, Object value) {
        switch (field) {
            case "build_corp_name":
            case "prj_name":
                if (value != null) {
                    this.setKeyword("%" + value.toString() + "%");
                }
                break;
            case "time_type":
                if (value.equals("prj_approval_date")) {
                    this.setPrj_approval_date_start(this.getTime_begin());
                    this.setPrj_approval_date_end(this.getTime_end());
                } else if (value.equals("tender_result_date")) {
                    this.setTender_result_date_start(this.getTime_begin());
                    this.setTender_result_date_end(this.getTime_end());
                } else if (value.equals("contract_date")) {
                    this.setContract_date_start(this.getTime_begin());
                    this.setContract_date_end(this.getTime_end());
                } else if (value.equals("release_date")) {
                    this.setRelease_date_start(this.getTime_begin());
                    this.setRelease_date_end(this.getTime_end());
                } else if (value.equals("begin_date")) {
                    this.setBegin_date_start(this.getTime_begin());
                    this.setBegin_date_end(this.getTime_end());
                } else if (value.equals("end_date")) {
                    this.setEnd_date_start(this.getTime_begin());
                    this.setEnd_date_end(this.getTime_end());
                } else {
                }
                this.dynamicSetProperty(field, value);
                break;
            case "company_type_label":
                if (operatorType.equals("in") && value instanceof ArrayList) {
                    String labels = Joiner.on(",").join(((ArrayList<?>) value));
                    this.setCompany_type_label(labels);
                }
                break;
            case "prj_type_num":
                if (operatorType.equals("in") && value instanceof ArrayList) {
                    String labels = Joiner.on(",").join(((ArrayList<?>) value));
                    this.setPrj_type_num(labels);
                }
                break;
            case "prj_property_num":
                if (operatorType.equals("in") && value instanceof ArrayList) {
                    String labels = Joiner.on(",").join(((ArrayList<?>) value));
                    this.setPrj_property_num(labels);
                }
                break;
            default:
                this.dynamicSetProperty(field, value);
        }
    }

}
